Skip to content

When linkifying HTML messages, give priority to explicit link tags #2879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jmartinesp
Copy link
Member

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • When linkification creates a new link from the HTML contents, remove it if it conflicts with an existing explicit link.

Motivation and context

Should fix #2291.

The method used for restoring URLSpans removed by the linkification process gave priority to the newly found links instead of the existing links the sender had explicitly set, which is wrong.

Also, it was especially hard to debug because the issue was focused in phone number being linkified and the detection of those phone numbers depend on the region code returned by the TelephonyManager service, which will vary from one device to another. It's a lot easier to spot with emails, i.e.

Tests

  • From EW or some other client, send a message like [test me@matrix.org](https://example.com) or its HTML equivalent.
  • From the app, open it. It should open https://example.com. Previously me@matrix.org would get linkified and replace the link to the website.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

@jmartinesp jmartinesp requested a review from a team as a code owner May 20, 2024 07:31
@jmartinesp jmartinesp requested review from ganfra and removed request for a team May 20, 2024 07:31
Copy link
Contributor

github-actions bot commented May 20, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/NrjZH7

Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 74.30%. Comparing base (29723a6) to head (f3babf8).
Report is 1 commits behind head on develop.

Files Patch % Lines
...ctories/event/TimelineItemContentMessageFactory.kt 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2879      +/-   ##
===========================================
+ Coverage    74.27%   74.30%   +0.02%     
===========================================
  Files         1530     1530              
  Lines        36521    36524       +3     
  Branches      7053     7054       +1     
===========================================
+ Hits         27127    27140      +13     
+ Misses        5708     5698      -10     
  Partials      3686     3686              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 20, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 20, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@jmartinesp jmartinesp added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 20, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 20, 2024
@jmartinesp jmartinesp merged commit 4919cd6 into develop May 20, 2024
25 checks passed
@jmartinesp jmartinesp deleted the fix/jme/2291-html-formatted-links-with-numbers-are-wrongly-formatted branch May 20, 2024 11:09
@bmarty
Copy link
Member

bmarty commented May 21, 2024

@jmartinesp I think this will fix the issue describe here: #2861 (comment), can you confirm please?

@jmartinesp
Copy link
Member Author

One of them, at least. You'd still be able to send [https://matrix.org](https://some-evil-site.com) and it would open the URL, not the text.

So I guess for that one we'd still need to somehow check if the text and URL in the link are both URLs and if there is some mismatch between them, then display some piece of UI to confirm you want to open the link?

@bmarty
Copy link
Member

bmarty commented May 21, 2024

OK, thanks.

Yes, I was talking about the issue: Actually, it seems that EXA is opening https://example.org/, which is a bug to also fix, but which is mitigating the problem.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTML formatted links with numbers are wrongly formatted
3 participants